<template>
  <div class="view-container">
    <el-header>
      <el-form :inline="true" class="demo-form-inline">
        <el-form-item label="">
          <el-input v-model="userALL.infoTitle" placeholder="标题"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="sleall">查询</el-button>
          <el-button type="primary" @click="userALL.infoTitle=null">重置</el-button>
          <el-button type="primary" @click="showDetail">修改</el-button>
          <el-button type="primary" @click="delHuiz">删除</el-button>
        </el-form-item>
      </el-form>
    </el-header>


    <el-main>
      <el-table
        ref="multipleTable"
        :data="tableData"
        tooltip-effect="dark"
        style="width: 100%"

        @select="handleSelectionChange"

        @row-click="btn_user"
      >

        <el-table-column
          type="selection"
          width="55">
        </el-table-column>
        <el-table-column
          label="标题"
          width="1000">
          <template slot-scope="scope"><el-link>{{ scope.row.infoTitle }}</el-link></template>
        </el-table-column>
        <el-table-column
          prop="infoUse"
          label="分类"
          show-overflow-tooltip>
        </el-table-column>
        <el-table-column
          prop="shareType"
          label="权限"
          show-overflow-tooltip>
        </el-table-column>

        <el-table-column
          prop="creatorName"
          label="发布人"
          show-overflow-tooltip>
        </el-table-column>

        <el-table-column
          prop="created"
          label="发布时间"
          show-overflow-tooltip>
        </el-table-column>

      </el-table>

      <div class="block">
        <span class="demonstration"></span>
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page.sync="currentPage2"
          :page-sizes="[5, 10, 15, 20]"
          :page-size="1"
          layout="sizes, prev, pager, next"
          :total=dataLoh>
        </el-pagination>
      </div>
    </el-main>



  </div>
</template>

<script>

  // huizongChakan
  import huizongsel from "@/api/huizongChakan/huizongsel";
  import listMixin from '@/mixin/listMixin'

  export default {
    name: "huizong",
    mixins:[listMixin],
    data() {
      return {
        pid:"",
        userALL:{
          infoTitle:"",//标题
          pageIndex:1,
          pageSize:5,
        },
        updateID:0,
        dataLoh:1,
        ids:[],
        currentPage2:5,
        formInline:{},
        tableData: [],
      }
    },
    created() {
    this.sleall()
    },
    methods: {


      //点击行获取ID
      btn_user(row) {
        console.log(row.infoId)
        this.showDetails(row.infoId)
      },
      //跳转修改页面
      showDetail(){
        this.$router.push('/work-exchange/huizongUp')
        this.$router.id = this.updateID
      },


      //跳转详情页面
      showDetails(id){
        this.$router.push('/work-exchange/xiangqing')
        this.$router.id = id
      },
      //分页
      handleSizeChange(val) {
        this.userALL.pageSize = val
        console.log(`每页 ${this.userALL.pageSize} 条`);
        this.sleall()
      },
      handleCurrentChange(val) {
        this.userALL.pageIndex = val

        console.log(`当前页: ${this.userALL.pageIndex}`);
        this.sleall()
      },
      //复选框事件
      handleSelectionChange(val) {
        this.updateID=val[0].infoId
        // console.log(val[0].infoId) ;
        this.ids=[]
        for (const i of val){
          this.ids[0]=i.infoId
          console.log(this.ids[0])
        }
      },
      //查询列表
      sleall(){
        huizongsel.huizongList(this.userALL).then(res=>{
          this.tableData = res.records
          this.dataLoh = res.total

          console.log(this.dataLoh)
        })
      },
      //删除
      delHuiz(){
        huizongsel.delHui(this.ids).then(res=>{
          this.sleall()
        })
      }

    }
  }
</script>

<style scoped lang="scss">

</style>
